package com.acmen.demo.api;

import com.acmen.demo.dto.cmd.UserAdd;
import com.acmen.demo.dto.cmd.UserUpd;
import com.acmen.demo.dto.query.UserListQry;
import com.acmen.demo.dto.query.UserPageQry;
import com.acmen.demo.dto.vo.UserVO;
import com.acmen.easyapi.annotation.RestApi;
import com.acmen.easyapi.model.CustomizePage;
import com.acmen.easyapi.model.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户RPC服务
 *
 * @author acmen
 */
@FeignClient(contextId = "userRemoteService",value = "acmen-demo")
public interface UserRemoteService {


    @GetMapping("/rpc/user/select-page")
    public Response<CustomizePage<UserVO>> selectPage(@SpringQueryMap UserPageQry query);

    /**
     * 获取用户列表
     */
    @GetMapping("/rpc/user/select-list")
    public Response<List<UserVO>> selectList(@SpringQueryMap UserListQry query);

    /**
     * 新增用户
     */
    @PostMapping("/rpc/user/create")
    @RestApi(name = "新增用户",idx = 2,author = "acmen")
    public Response create(@RequestBody UserAdd user);

    /**
     * 修改用户
     */
    @PutMapping("/rpc/user/update")
    public Response update(@RequestBody UserUpd user);

    /**
     * 删除用户
     */
    @DeleteMapping("/rpc/user/delete")
    public Response delete(@RequestBody List<Long> ids);


    @GetMapping("/rpc/user/{id}")
    public Response<UserVO> selectById(@PathVariable("id") Long id);

}
